ValueFolderTemp='/sps/isc/rneveu/EtudeIRM/Nature/ResultsJournal/';
VecValueTime=[1 2 3 4 5 10 0];
VecValueFilter=[1];
VecResultsFigure=[];
for n5=1:size(VecValueTime,2)
    for n6=1:size(VecValueFilter,2)
        ValueTime=VecValueTime(1,n5);
        ValueFilter=VecValueFilter(1,n6);
        n1=32;
        if ValueTime>=1
            if ValueFilter==0
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Journal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Filtered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        else
            if ValueFilter==0
                ValueFile=['FileAnalysisJournal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysisFiltered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        end
        load([ValueFolderTemp ValueFile]);
        n2=1;
        TestTemp=0;
        while n2<=size(VecResultsArticle2,1)&&TestTemp==0
            if VecResultsArticle2(n2,4)>0
                TestTemp=1;
            end
            n2=n2+1;
        end
        VecValueTemp32=VecResultsArticle2(n2-1:end,:);
        VecValue2Temp32=VecResultsArticle1(n2-1:end,:);
        n1=33;
        if ValueTime>=1
            if ValueFilter==0
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Journal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Filtered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        else
            if ValueFilter==0
                ValueFile=['FileAnalysisJournal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysisFiltered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        end
        load([ValueFolderTemp ValueFile]);
        n2=1;
        TestTemp=0;
        while n2<=size(VecResultsArticle2,1)&&TestTemp==0
            if VecResultsArticle2(n2,4)>0
                TestTemp=1;
            end
            n2=n2+1;
        end
        VecValueTemp33=VecResultsArticle2(n2-1:end,:);
        VecValue2Temp33=VecResultsArticle1(n2-1:end,:);
        VecResults=[];
        VecResults2=[];
        for n1=1:33
            if n1~=32
                if ValueTime>=1
                    if ValueFilter==0
                        ValueFile=['FileAnalysis' num2str(ValueTime) 'Journal' num2str(n1) '.mat'];
                    else
                        ValueFile=['FileAnalysis' num2str(ValueTime) 'Filtered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
                    end
                else
                    if ValueFilter==0
                        ValueFile=['FileAnalysisJournal' num2str(n1) '.mat'];
                    else
                        ValueFile=['FileAnalysisFiltered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
                    end
                end
                ValueFileTemp=dir([ValueFolderTemp ValueFile]);
                load([ValueFolderTemp ValueFile]);
                n2=1;
                TestTemp=0;
                while n2<=size(VecResultsArticle2,1)&&TestTemp==0
                    if VecResultsArticle2(n2,4)>0
                        TestTemp=1;
                    end
                    n2=n2+1;
                end
                VecValueTemp=VecResultsArticle2(n2-1:end,:);
                VecValue2Temp=VecResultsArticle1(n2-1:end,:);
                if VecValueTemp(1,3)>0&&VecValue2Temp(1,3)>0
                    % Year of the luanch of the new journal-year before the year of the launch of the new journal
                    VecResults=[VecResults;VecValueTemp(1,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,1)+VecValueTemp(1,1) -size(VecValueTemp,1)+1];
                    if size(VecValueTemp,1)>1
                        % Year after the the year of the launch of a new journal-year before the year of the launch of the new journal
                        VecResults2=[VecResults2;VecValueTemp(2,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,1)+VecValueTemp(2,1) -size(VecValueTemp,1)+1];
                    end
                end
            end
        end
        [ValueResults,stats]=robustfit(VecResults(:,end),VecResults(:,7)-VecResults(:,6));
        VecResultsFigure=[VecResultsFigure;ValueResults' stats.se' stats.p'];
    end
end
VecValueTime=[2];
VecValueFilter=[0];
for n5=1:size(VecValueTime,2)
    for n6=1:size(VecValueFilter,2)
        ValueTime=VecValueTime(1,n5);
        ValueFilter=VecValueFilter(1,n6);
        n1=32;
        if ValueTime>=1
            if ValueFilter==0
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Journal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Filtered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        else
            if ValueFilter==0
                ValueFile=['FileAnalysisJournal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysisFiltered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        end
        load([ValueFolderTemp ValueFile]);
        n2=1;
        TestTemp=0;
        while n2<=size(VecResultsArticle2,1)&&TestTemp==0
            if VecResultsArticle2(n2,4)>0
                TestTemp=1;
            end
            n2=n2+1;
        end
        VecValueTemp32=VecResultsArticle2(n2-1:end,:);
        VecValue2Temp32=VecResultsArticle1(n2-1:end,:);
        n1=33;
        if ValueTime>=1
            if ValueFilter==0
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Journal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Filtered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        else
            if ValueFilter==0
                ValueFile=['FileAnalysisJournal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysisFiltered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        end
        load([ValueFolderTemp ValueFile]);
        n2=1;
        TestTemp=0;
        while n2<=size(VecResultsArticle2,1)&&TestTemp==0
            if VecResultsArticle2(n2,4)>0
                TestTemp=1;
            end
            n2=n2+1;
        end
        VecValueTemp33=VecResultsArticle2(n2-1:end,:);
        VecValue2Temp33=VecResultsArticle1(n2-1:end,:);
        VecResults=[];
        VecResults2=[];
        for n1=1:33
            if n1~=32
                if ValueTime>=1
                    if ValueFilter==0
                        ValueFile=['FileAnalysis' num2str(ValueTime) 'Journal' num2str(n1) '.mat'];
                    else
                        ValueFile=['FileAnalysis' num2str(ValueTime) 'Filtered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
                    end
                else
                    if ValueFilter==0
                        ValueFile=['FileAnalysisJournal' num2str(n1) '.mat'];
                    else
                        ValueFile=['FileAnalysisFiltered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
                    end
                end
                ValueFileTemp=dir([ValueFolderTemp ValueFile]);
                load([ValueFolderTemp ValueFile]);
                n2=1;
                TestTemp=0;
                while n2<=size(VecResultsArticle2,1)&&TestTemp==0
                    if VecResultsArticle2(n2,4)>0
                        TestTemp=1;
                    end
                    n2=n2+1;
                end
                VecValueTemp=VecResultsArticle2(n2-1:end,:);
                VecValue2Temp=VecResultsArticle1(n2-1:end,:);
                if VecValueTemp(1,3)>0&&VecValue2Temp(1,3)>0
                    % Year of the luanch of the new journal-year before the year of the launch of the new journal
                    VecResults=[VecResults;VecValueTemp(1,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,1)+VecValueTemp(1,1) -size(VecValueTemp,1)+1];
                    if size(VecValueTemp,1)>1
                        % Year after the the year of the launch of a new journal-year before the year of the launch of the new journal
                        VecResults2=[VecResults2;VecValueTemp(2,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,1)+VecValueTemp(2,1) -size(VecValueTemp,1)+1];
                    end
                end
            end
        end
        [ValueResults,stats]=robustfit(VecResults(:,end),VecResults(:,7)-VecResults(:,6));
    end
end
VecValueFigure=[VecResults(:,7) VecResults(:,6) VecResults(:,end)+2020 VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100 VecResults(:,6)./VecResults(:,2)*100];
[ValueResults,stats]=robustfit(VecResults(:,end),VecResults(:,7)-VecResults(:,6));
% save([ValueFolderTemp 'FichierFigureRobustnessStartNewJournal.mat'],'VecResultsFigure','VecValueFigure','ValueResults','stats');

return

% Analysis for the figure of the main text
VecValueTime=[2];
VecValueFilter=[0];
for n5=1:size(VecValueTime,2)
    for n6=1:size(VecValueFilter,2)
        ValueTime=VecValueTime(1,n5);
        ValueFilter=VecValueFilter(1,n6);
        n1=32;
        if ValueTime>=1
            if ValueFilter==0
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Journal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Filtered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        else
            if ValueFilter==0
                ValueFile=['FileAnalysisJournal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysisFiltered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        end
        load([ValueFolderTemp ValueFile]);
        n2=1;
        TestTemp=0;
        while n2<=size(VecResultsArticle2,1)&&TestTemp==0
            if VecResultsArticle2(n2,4)>0
                TestTemp=1;
            end
            n2=n2+1;
        end
        VecValueTemp32=VecResultsArticle2(n2-1:end,:);
        VecValue2Temp32=VecResultsArticle1(n2-1:end,:);
        n1=33;
        if ValueTime>=1
            if ValueFilter==0
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Journal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysis' num2str(ValueTime) 'Filtered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        else
            if ValueFilter==0
                ValueFile=['FileAnalysisJournal' num2str(n1) '.mat'];
            else
                ValueFile=['FileAnalysisFiltered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
            end
        end
        load([ValueFolderTemp ValueFile]);
        n2=1;
        TestTemp=0;
        while n2<=size(VecResultsArticle2,1)&&TestTemp==0
            if VecResultsArticle2(n2,4)>0
                TestTemp=1;
            end
            n2=n2+1;
        end
        VecValueTemp33=VecResultsArticle2(n2-1:end,:);
        VecValue2Temp33=VecResultsArticle1(n2-1:end,:);
        VecResults=[];
        VecResults2=[];
        for n1=1:33
            if n1~=32
                if ValueTime>=1
                    if ValueFilter==0
                        ValueFile=['FileAnalysis' num2str(ValueTime) 'Journal' num2str(n1) '.mat'];
                    else
                        ValueFile=['FileAnalysis' num2str(ValueTime) 'Filtered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
                    end
                else
                    if ValueFilter==0
                        ValueFile=['FileAnalysisJournal' num2str(n1) '.mat'];
                    else
                        ValueFile=['FileAnalysisFiltered' num2str(ValueFilter) 'Journal' num2str(n1) '.mat'];
                    end
                end
                ValueFileTemp=dir([ValueFolderTemp ValueFile]);
                load([ValueFolderTemp ValueFile]);
                n2=1;
                TestTemp=0;
                while n2<=size(VecResultsArticle2,1)&&TestTemp==0
                    if VecResultsArticle2(n2,4)>0
                        TestTemp=1;
                    end
                    n2=n2+1;
                end
                VecValueTemp=VecResultsArticle2(n2-1:end,:);
                VecValue2Temp=VecResultsArticle1(n2-1:end,:);
                if VecValueTemp(1,3)>0&&VecValue2Temp(1,3)>0
                    % Year of the luanch of the new journal-year before the year of the launch of the new journal
                    VecResults=[VecResults;VecValueTemp(1,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+1,1)+VecValueTemp(1,1) -size(VecValueTemp,1)+1];
                    if size(VecValueTemp,1)>1
                        % Year after the the year of the launch of a new journal-year before the year of the launch of the new journal
                        VecResults2=[VecResults2;VecValueTemp(2,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,1)/VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,3) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1),1) VecValueTemp32(size(VecValueTemp32,1)-size(VecValueTemp,1)+2,1)+VecValueTemp(2,1) -size(VecValueTemp,1)+1];
                    end
                end
            end
        end
        [ValueResults,stats]=robustfit(VecResults(:,end),VecResults(:,7)-VecResults(:,6));
    end
end
VecValueFigure=[VecResults(:,7) VecResults(:,6) VecResults(:,end)+2020 VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100 VecResults(:,6)./VecResults(:,2)*100];
% VecResults(:,end)=VecResults(:,end)+abs(min(VecResults(:,end)));
[ValueResults,ValueResults2]=ttest(VecResults(:,2),VecResults(:,3));
ValueResults=signrank(VecResults(:,2),VecResults(:,3));
% Comparison of total number of original articles over Nature and the new journal between before launch et after launch
[ValueResults,ValueResults2]=ttest(VecResults(:,2),VecResults(:,3)+VecResults(:,1));
ValueResults=signrank(VecResults(:,2),VecResults(:,3)+VecResults(:,1));
VecResults6=[mean(VecResults(:,2)) sqrt(var(VecResults(:,2))) mean(VecResults(:,3)+VecResults(:,1)) sqrt(var(VecResults(:,3)+VecResults(:,1))) mean(VecResults(:,2)-(VecResults(:,3)+VecResults(:,1))) sqrt(var(VecResults(:,2)-(VecResults(:,3)+VecResults(:,1)))) ValueResults ValueResults2]
% Fit over time of the difference in total number of original articles in Nature and the new journal between after launch and before launch
[ValueResults2,stats]=robustfit(VecResults(:,end),VecResults(:,3)+VecResults(:,1)-VecResults(:,2));
[ValueResults2,table,stats2]=anovan(VecResults(:,3)+VecResults(:,1)-VecResults(:,2),{VecResults(:,end)},'continuous',1,'model','full','display','off');
% Fit over time of the difference in total number of original articles with only new authors in Nature and the new journal between after launch and before launch
[ValueResults,stats]=robustfit(VecResults(:,end),VecResults(:,7)-VecResults(:,6));
[ValueResults,table,stats]=anovan(VecResults(:,7)-VecResults(:,6),{VecResults(:,end)},'continuous',1,'model','full','display','off');
[ValueResults,ValueResults2]=corr(VecResults(:,7)-VecResults(:,6),VecResults(:,end),'type','spearman')

return

% Same thing but with the ratios
[ValueResults,ValueResults2]=ttest(VecResults(:,6)./VecResults(:,2)*100,VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100);
ValueResults=signrank(VecResults(:,6)./VecResults(:,2)*100,VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100);
VecResults6=[VecResults6;mean(VecResults(:,6)./VecResults(:,2)*100) sqrt(var(VecResults(:,6)./VecResults(:,2)*100)) mean(VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100) sqrt(var(VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100)) mean(VecResults(:,6)./VecResults(:,2)*100-VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100) sqrt(var(VecResults(:,6)./VecResults(:,2)*100-VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100)) ValueResults ValueResults2]
% Fit over time of the difference in total number of original articles with only new authors in Nature and the new journal between after launch and before launch
[ValueResults,stats]=robustfit(VecResults(:,end),VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100-VecResults(:,6)./VecResults(:,2)*100);
[ValueResults,table,stats]=anovan(VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100-VecResults(:,6)./VecResults(:,2)*100,{VecResults(:,end)},'continuous',1,'model','full','display','off');
[ValueResults,ValueResults2]=corr(VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100-VecResults(:,6)./VecResults(:,2)*100,VecResults(:,end),'type','spearman')
plot(VecResults(:,7)./(VecResults(:,3)+VecResults(:,1))*100-VecResults(:,6)./VecResults(:,2)*100,VecResults(:,end),'+')

save([ValueFolderTemp 'FichierAnalyseStartNewJournal.mat'],'VecValueFigure');


